package cn.zyq.demo.system.enums;

import cn.zyq.demo.system.enums.core.ResponseCodeEnum;
import cn.zyq.demo.system.exception.BusinessException;

/**
 * 系统配置key
 */
public enum SysConfigTypeEnum {
    RUN_ORDER_SERVICE_CHARGE("跑腿服务费率key", "run_order_service_charge"),
    ACTIVITY_EVERYDAY_FREE_VOTE("活动投票每日免费次数key", "activity_everyday_free_vote_num"),
    ;
    private String key;
    private String value;

    private SysConfigTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public static String getKeyByValue(String value) {
        for (SysConfigTypeEnum item : SysConfigTypeEnum.values()) {
            if (item.value.equals(value)) return item.key;
        }
        throw new BusinessException(ResponseCodeEnum.ERROR.ERROR, "无效的value值");
    }

    public String getValue() {
        return value;
    }

    public String getKey() {
        return key;
    }

}
